package com.hoangkien.service;

import java.util.ArrayList;

import com.hoangkien.DAO.CreateDatabase;
import com.hoangkien.DAO.ImageDAO;
import com.hoangkien.entity.ImageEntity;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class ImageService {
	private Context context;

	public ImageService(Context context) {
		this.context = context;
	}

	public long insert_image(ImageEntity imageEntity) {
		CreateDatabase createDb = new CreateDatabase(context);
		SQLiteDatabase db = createDb.open();
		ImageDAO imageDAO = new ImageDAO(db);
		long result = imageDAO.insert_image(imageEntity);
		db.close();
		createDb.close();
		return result;
	}
	
	public ArrayList<ImageEntity> getAllImage(){
		CreateDatabase createDb = new CreateDatabase(context);
		SQLiteDatabase db = createDb.open();
		ImageDAO imageDAO =  new ImageDAO(db);
		ArrayList<ImageEntity> lisImageEntity = new ArrayList<ImageEntity>();
		lisImageEntity = imageDAO.getAllImage();
		db.close();
		createDb.close();
		return lisImageEntity;
	}
}
